using System;

namespace LeetCode {
    public class Recursion {
        public bool isMatch (string s, string p) {
            if (p.Length <= 0) {
                return s.Length <= 0;
            }
            bool CurMatch = (s.Length >= 0) && ((s[0] == p[0]) || p[0] == '.');
            if (p.Length > 1 && p[1] == '*') {
                return isMatch (s, p.Substring (2)) || (isMatch (s.Substring (1), p) && CurMatch);
            } else {
                return CurMatch && isMatch (s.Substring (1), p.Substring (1));
            }
        }
    }
}